//
//  TogetherDetailController.m
//  i5db
//
//  Created by iMuse on 15-5-14.
//  Copyright (c) 2015年 mySelf. All rights reserved.
//

#import "TogetherDetailController.h"
#import "APPView.h"
#import "AppCenter.h"
#import "MapNavgationController.h"

@interface TogetherDetailController ()
{
    UIScrollView * scrollView;
    UIView       * contentView;
    
    UIView       * headView;
    UIImageView  * backgroundView;
    
    UILabel      * titleLabel;
    
    UILabel      * locationLabel;
    
    UILabel      * timeLabel;
    
    UIButton     * bmButton;
    
    UILabel      * numberLabel;
    
    UILabel      * contenLabel;
}

@end

@implementation TogetherDetailController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = @"活动详情";
    }
    return self;
}
-(void)initNavigationBar
{
    [super initNavigationBar];
}
-(void)updateViewConstraints
{
    [super updateViewConstraints];
    
    
    [headView autoPinToTopLayoutGuideOfViewController:self withInset:0];
    [headView autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:0];
    [headView autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:0];
    [headView autoSetDimension:ALDimensionHeight toSize:SCREEN_HEIGHT/2-50];
    [backgroundView autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
    
    [titleLabel autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:10];
    [titleLabel autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:10];
    [titleLabel autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:10];
    [titleLabel autoSetDimension:ALDimensionHeight toSize:50];
    
    [scrollView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:headView withOffset:0];
    [scrollView autoPinToBottomLayoutGuideOfViewController:self withInset:0];
    [scrollView autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:0];
    [scrollView autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:0];
   
    [contentView autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:scrollView withOffset:0];
    [contentView autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:scrollView withOffset:0];
    [contentView autoPinEdge:ALEdgeLeft toEdge:ALEdgeLeft ofView:scrollView withOffset:0];
    [contentView autoPinEdge:ALEdgeRight toEdge:ALEdgeRight ofView:scrollView withOffset:0];
    
    [contentView autoSetDimension:ALDimensionWidth toSize:SCREEN_WIDTH];

}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.view setNeedsUpdateConstraints];
    [self initNavigationBar];
    [self initView];
    
}
-(void)initView
{
    headView = [UIView newAutoLayoutView];
    [self.view addSubview:headView];
    
    UITapGestureRecognizer* tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(baiduCustom:)];
    [headView addGestureRecognizer:tapGesture];
    backgroundView = [UIImageView newAutoLayoutView];
    backgroundView.image = [UIImage imageNamed:@"pic02.jpg"];
    [headView addSubview:backgroundView];
    
    UIView* blackView = [UIView newAutoLayoutView];
    blackView.backgroundColor = [UIColor blackColor];
    blackView.alpha = 0.7;
    [headView addSubview:blackView];
    [blackView autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
    
    titleLabel = [UILabel newAutoLayoutView];
    titleLabel.font = [UIFont boldSystemFontOfSize:16];
    titleLabel.text = @"一场只属于单身贵族的Party【北京单身精品聚餐";
    titleLabel.numberOfLines = 0;
    titleLabel.textColor = [AppCenter color:@"254,254,254,1"];
    [headView addSubview:titleLabel];
    
    UIImageView * locationView = [UIImageView newAutoLayoutView];
    locationView.image = [UIImage imageNamed:@"fujin.png"];
    [headView addSubview:locationView];
    [locationView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:titleLabel withOffset:20];
    [locationView autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:10];
    [locationView autoSetDimensionsToSize:CGSizeMake(10, 12)];
    
    locationLabel = [UILabel newAutoLayoutView];
    locationLabel.text = @"欢乐谷";
    locationLabel.textColor = [AppCenter color:@"254,254,254,1"];
    locationLabel.font = [UIFont systemFontOfSize:12];
    [headView addSubview:locationLabel];
    
    [locationLabel autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:titleLabel withOffset:20];
    [locationLabel autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:locationView withOffset:5];
    [locationLabel autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:10];
    [locationLabel autoSetDimension:ALDimensionHeight toSize:12];
    
    
    UIImageView* timeView = [UIImageView newAutoLayoutView];
    timeView.image = [UIImage imageNamed:@"fujin.png"];
    [headView addSubview:timeView];
    [timeView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:locationView withOffset:10];
    [timeView autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:10];
    [timeView autoSetDimensionsToSize:CGSizeMake(10, 12)];
    
    timeLabel  = [UILabel newAutoLayoutView];
    timeLabel.text = @"5月12日 12:00 - 5月12日 17:00";
    timeLabel.font = locationLabel.font;
    timeLabel.textColor = locationLabel.textColor;
    [headView addSubview:timeLabel];
    
    [timeLabel autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:locationLabel withOffset:10];
    [timeLabel autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:timeView withOffset:5];
    [timeLabel autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:10];
    [timeLabel autoSetDimension:ALDimensionHeight toSize:12];
    
    bmButton = [UIButton newAutoLayoutView];
    [bmButton setTitle:@"我要参加" forState:UIControlStateNormal];
    bmButton.titleLabel.font = [UIFont boldSystemFontOfSize:16];
    [bmButton setTitleColor:[AppCenter color:@"254,254,254,1"] forState:UIControlStateNormal];
    bmButton.layer.borderWidth = 1;
    bmButton.layer.cornerRadius = 3;
    bmButton.layer.borderColor = [UIColor whiteColor].CGColor;
    [headView addSubview:bmButton];
    [bmButton autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:timeLabel withOffset:10];
    [bmButton autoAlignAxisToSuperviewAxis:ALAxisVertical];
    [bmButton autoSetDimensionsToSize:CGSizeMake(120, 40)];
    
    numberLabel = [UILabel newAutoLayoutView];
    numberLabel.text = @"160人已报名";
    numberLabel.textAlignment = NSTextAlignmentCenter;
    numberLabel.font = timeLabel.font;
    numberLabel.textColor =timeLabel.textColor;
    [headView addSubview:numberLabel];
    [numberLabel autoAlignAxisToSuperviewAxis:ALAxisVertical];
    [numberLabel autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:bmButton withOffset:5];
    [numberLabel autoSetDimensionsToSize:CGSizeMake(320, 12)];
    
    scrollView = [UIScrollView newAutoLayoutView];
   
    scrollView.showsVerticalScrollIndicator = NO;
    [self.view addSubview:scrollView];
    
    contentView = [UIView newAutoLayoutView];
    contentView.backgroundColor = [UIColor whiteColor];
    
    [scrollView addSubview:contentView];
    
    
    UILabel * activityLabel = [UILabel newAutoLayoutView];
    activityLabel.text = @"主办方介绍";
    activityLabel.textColor = [AppCenter color:@"165,165,165,1"];
    activityLabel.font      = [UIFont systemFontOfSize:14];
    [contentView addSubview:activityLabel];
    [activityLabel autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:10];
    [activityLabel autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:10];
    [activityLabel autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:10];
    
    contenLabel = [UILabel newAutoLayoutView];
    contenLabel.text = @"1、条理一定要清楚，分类要合理，一般包括以下几部分：活动目的、可行性分析、活动内容(这个最重要)、分工(含工作推进)、预算2、活动内容这一块应包含以下几个方面的内容：宣传(包含宣传形式以及宣传日程)报名(又叫参赛方式，含报名时间、报名方式、参赛要求等等)活动形式(这才是真正意义上的活动内容，包括活动分为哪几个环节，每个环节都是些什么内容，如果是体育类比赛就应包含赛程赛制规则等等。)活动流程(这个应从两方面写，一是大流程，即整个活动期间各个环节应该干的事，什么时候宣传，什么时候都是哪个阶段的比赛等等;二是小流程，即正式比赛或活动当天的流程，严格来讲这一部分的流程不应出现工作人员要干的事情，而只出现活动相关的内容，类似于晚会节目单，只出现观众和比赛人员应知道的流程。一般情况给外人看的策划只出现小流程)评奖(含奖项设置、评奖办法、平分细则等等),注意事项(具体活动具体分析)3、分工要按照“工种”给工作人员分类，同时著名各项工作完成时限(这一块一定要细，要责任到人)4、预算要合理(实地考查)、有周转空间、同时应学会“该花的不能吝啬，该省的一定要省”5、如果是要拉赞助的活动一定要单独做赞助邀请6、策划的语言一定要精炼、书面化，不能罗嗦或是出现大白话7、策划要讲求格式统一，该空行的地方统一空行，包括行间距、字体大小、缩进度都得保持一样，这样才清楚整齐。";
    contenLabel.font = activityLabel.font;
    contenLabel.numberOfLines = 0;
    contenLabel.textColor = activityLabel.textColor;
    [contentView addSubview:contenLabel];
    
    [contenLabel autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:activityLabel withOffset:5];
    [contenLabel autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:10];
    [contenLabel autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:10];
    
   CGSize size = [AppCenter sizeWithString:contenLabel.text font:contenLabel.font maxHeight:1000 maxWeight:SCREEN_WIDTH];

    [contentView autoSetDimension:ALDimensionHeight toSize:size.height+60];
    

    
}
-(void)baiduCustom:(UITapGestureRecognizer*) sender
{
    MapNavgationController * controller = [[MapNavgationController alloc] init];
    [self.navigationController pushViewController:controller animated:YES];
}

- (void)viewWillAppear:(BOOL)animated {
    [[self rdv_tabBarController] setTabBarHidden:YES animated:YES];
    [super viewWillAppear:animated];
    
    
}

- (void)viewWillDisappear:(BOOL)animated {
    
    [[self rdv_tabBarController] setTabBarHidden:NO animated:YES];
    
    [super viewWillDisappear:animated];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
 
}



@end
